libobs_wrapper\utils\traits/
mod.rs

1use crate::{
2    data::{immutable::ImmutableObsData, ObsData, ObsObjectUpdater},
3    runtime::ObsRuntime,
4};
5
6use super::ObsError;
7
8#[cfg_attr(not(feature="blocking"), async_trait::async_trait)]
9pub trait ObsUpdatable {
10    /// Updates the object with the current settings.
11    /// For examples please take a look at the [Github repository](https://github.com/joshprk/libobs-rs/blob/main/examples).
12    #[cfg_attr(feature = "blocking", remove_async_await::remove_async_await)]
13    async fn create_updater<'a, T: ObsObjectUpdater<'a, ToUpdate = Self> + Send + Sync>(
14        &'a mut self,
15    ) -> Result<T, ObsError>
16    where
17        Self: Sized + Send + Sync,
18    {
19        let runtime = self.runtime();
20        T::create_update(runtime, self).await
21    }
22
23    fn runtime(&self) -> ObsRuntime;
24
25    // We don't really need a mut here, but we do it anyway to give the dev a *feeling* of changing something
26    #[cfg_attr(feature = "blocking", remove_async_await::remove_async_await)]
27    async fn update_raw(&mut self, data: ObsData) -> Result<(), ObsError>;
28    #[cfg_attr(feature = "blocking", remove_async_await::remove_async_await)]
29    async fn reset_and_update_raw(&mut self, data: ObsData) -> Result<(), ObsError>;
30
31    #[cfg_attr(feature = "blocking", remove_async_await::remove_async_await)]
32    async fn get_settings(&self) -> Result<ImmutableObsData, ObsError>;
33}